import java.io.*;
import java.net.*;

public class client {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		String hostName = null;
		String clientname = null;
		
		BufferedReader stdIn = new BufferedReader(  new InputStreamReader(System.in));
		System.out.print("Nhap hostname: ");
		hostName = stdIn.readLine();
		System.out.print("Nhap ten cua ban: ");
		clientname = stdIn.readLine();
		
		int portNumber = 35800;
		try(
				Socket echoSocket = new Socket(hostName, portNumber);
			    PrintWriter out = new PrintWriter(echoSocket.getOutputStream(), true);
			    BufferedReader in =  new BufferedReader( new InputStreamReader(echoSocket.getInputStream()));
		){
			System.out.print("Connected");
			String userInput;
			while ((userInput = stdIn.readLine()) != null) {
			    out.println(clientname + ": " + userInput);
			    System.out.println(in.readLine());
			}
		}
		catch (IOException e)
		{
			
		}

	}

}
